
var config = require(__MAIN__ + '/config.ts')
var functions = require(__LIBS__ + '/functions.ts')
module.exports = require('angular')
    .module('services.login', [])
    .factory('login', ($http) => {
        return {
            getUserData: function () {
                return $http.jsonp(config.urlGetUserData + '?callback=JSON_CALLBACK')
            },
            userLogin: function (userData) {
                userData = angular.extend({
                    uname: '',
                    password: '',
                    forward: '/',
                    rememberAccount: false,
                    rememberPassword: false,
                    autoRedirecting: true
                }, userData)
                return $http.jsonp(config.urlUserLogin + '?callback=JSON_CALLBACK' + functions.urlEncode(userData))
            },
            userLogout: function () {
                return $http.jsonp(config.urlUserLogout + '?callback=JSON_CALLBACK')
            },
            checkRole: function (sid) {
                return $http.jsonp(config.urlCheckRole + '?callback=JSON_CALLBACK&sid=' + sid)
            }
        }
    })

